<%--
  Created by IntelliJ IDEA.
  User: 陈鹏
  Date: 2021/3/27
  Time: 14:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
index
<div class="remark-pox">
    {{Test}}
    <table>
        <thead>
        <tr>
            <td>uid</td>
            <td>content</td>
            <td>operation</td>
        </tr>
        </thead>
        <tbody>
        <tr v-for="remark in remarks">
            <th>{{remark.uid}}</th>
            <th>{{remark.content}}</th>
            <th><button>回复</button><button @click="_deleteRemarkForNove(remark.rid)">删除</button></th>
        </tr>
        </tbody>
    </table>
</div>
<script src="/comms/vue.js"></script>
<script src="/comms/jquery.js"></script>
<script>
    function request(url, method, fn, data) {
        $.ajax({
            url: url,
            data: data,
            method: method,
            dataType: "json",
            success: fn
        })
    }</script>
<script>
    let v=new Vue({
        el:".remark-pox",
        data:{
            Test:"章节评论",
            remarks:[],
            nid:"1005",
            rid:"1000",
            chapterid:"8"
        },
        created:function () {
            console.log("创建");
            this.initRemark();
        },
        methods:{
            initRemark:function (nid) {
                let this_ = this;
                request("/remark/selectRemarkForChapter?nid="+this.nid+"&chapterid="+this.chapterid, "GET", function (data) {
                    if (data.flag) {
                        this_.remarks = data.data;
                    } else {
                        console.log("noData")
                    }
                })
            },

            /*删除总评*/
            _deleteRemarkForNove:function (id) {
                console.log(id)
                let this_=this;
                request("/remark/deleteRemarkForNovel?rid="+this.rid, "POST", function (data) {
                    if (data.flag) {
                        this_.initRemark(this_.nid);
                    } else {
                        console.log("deleteFailed")
                    }
                })
            }
        }
    })
</script>
</body>
</html>
